package org.example.infrastructure.common.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public abstract class BaseDO<I extends Serializable> implements Serializable {

    /**
     * 逻辑删除字段(0：未删除；主键：已删除)
     */
    @TableField(value = "is_deleted")
    @TableLogic(value = "0", delval = "id")
    private Integer isDeleted;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 用于实现延迟加载(懒加载)
     */
    @TableField(exist = false)
    private Boolean loadFlag = true;

    /**
     * 获取主键
     */
    public abstract I getPrimaryId();

    /**
     * 设置主键
     */
    public abstract void setPrimaryId(I id);
}
